﻿Public Class clsGTGBBMWDJC

    Public Function insert(en As entityGTGBBMWDJC) As Integer
        Dim sql As String = String.Empty
        Dim rtn As Integer
        sql &= "INSERT INTO sf.b_gt_gtgbbmwdjc( factory_id , technology_id , oper_date , gjb_type , surface_temp , surface_abnormal , oper , update_time) "
        sql &= "VALUES ( ?, ? , ? , ? , ? , ? , ? , (SELECT CURRENT_TIMESTAMP(6)))"
        With en
            rtn = DBacs.ExecuteUpdateSql(sql, -1, .factory_id, .technology_id, .oper_date, .gjb_type, .surface_temp, .surface_abnormal, .oper)
        End With
        Return rtn
    End Function

    Public Function update(en As entityGTGBBMWDJC) As Integer
        Dim sql As String = String.Empty
        Dim rtn As Integer
        sql &= " UPDATE sf.b_gt_gtgbbmwdjc SET oper_date = ? , gjb_type = ? , surface_temp = ? , surface_abnormal = ? , update_time = (SELECT CURRENT_TIMESTAMP(6))"
        sql &= " WHERE sys_id = ? "
        With en
            rtn = DBacs.ExecuteUpdateSql(sql, -1, .oper_date, .gjb_type, .surface_temp, .surface_abnormal, .sys_id)
        End With
        Return rtn
    End Function

    Public Function selectBySysid(_sysid As String) As DataTable
        Dim szSql As String = "select a.*,b.requirement,b.control_point from sf.b_gt_gtgbbmwdjc a left join sf.t_mst_technology b on a.technology_id::integer = b.sys_id where a.factory_id=? and a.sys_id=?"
        Return DBacs.ExecuteSql(szSql, -1, "TS", _sysid)
    End Function

    Public Function getList(startTime As String, endTime As String) As DataTable
        Dim szSql As String = ""
        szSql &= " select * from sf.b_gt_gtgbbmwdjc "
        szSql &= " where 1=1 "
        If startTime <> "" Then
            szSql &= " and update_time >= '" + startTime + "'"
        End If
        If endTime <> "" Then
            szSql &= " and update_time <= '" + endTime + "'"
        End If
        Return DBacs.ExecuteSql(szSql, -1)
    End Function


End Class
